home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Development Notes / Profiling with CodeWarrior < prev   
Encoding:
Text File  |  1996-09-17  |  5.5 KB  |  108 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. Profiling with CodeWarrior
  6. ODF Release 2                                                                                                                                                            
  7.  
  8. This document provides information about profiling your code using Metrowerks CodeWarrior.
  9.  
  10.  
  11. Table of Contents
  12. -------------------------
  13. • Building ODFCWProfilerLib
  14. • Profiling the ODF Shared Library
  15. • Profiling ODF Static Libraries
  16. • Automatic Modification of ODF Libraries
  17. • Modifying Your Part
  18. • Enabling Profiling
  19.  
  20. It is possible to use the performance profiling tools included in the Metrowerks CodeWarrior toolset to generate performance measurements for PowerPC OpenDoc parts built with ODF.  It is not currently possible to profile 68k parts built with ODF. This document describes the CWPPCProfiler library and the steps necessary to configure profiling for an ODF part. Detailed information on the Metrowerks CodeWarrior Profiler can be found in the CodeWarrior documentation.
  21.  
  22.  
  23.  
  24. Building ODFCWProfilerLib
  25.  
  26. Profiling of ODF-based parts is based on the ODFCWProfilerLib shared library. This library is not provided in its built state. To build the library, open the CodeWarrior project at the path “ODFDev:ODF:Tools:Mac:CWPPCProfiler:ODFCWProfilerLib.π”. Build the library by selecting “Make” from the “Project” menu in CodeWarrior. The built library will be created as “ODFDev:ODF:Tools:Mac:ODFCWProfilerLib.PPC”.
  27.  
  28.  
  29.  
  30. Profiling the ODF Shared Library
  31.  
  32. During the process of profiling your part editor, you may find it useful to generate profiler data for the ODF shared library.  Profiling the shared libary requires the following modifications:
  33.  
  34. 1. Open the “ODFDev:ODF:SLPPCDebug:ODFLibrary.π” project in CodeWarrior. 
  35.  
  36. 2. Open the “PPC CodeGen” panel of the preferences dialog. Check the “Use Profiler” checkbox.
  37.  
  38. 3. Add the ODFCWProfilerLib.PPC library you built earlier to the ODFLibrary project. Rebuild the ODFLibrary and replace the version in your Extensions folder with the new version.
  39.  
  40.  
  41.  
  42. Profiling ODF Static Libraries
  43.  
  44. During the process of profiling your part editor, you may find it useful to generate profiler data for one or more of the ODF static libraries. Profiling the static libraries requires the following modifications to each of the static libraries (Foundation, OS, Framework) that you wish to profile:
  45.  
  46. 1. Open the  project in CodeWarrior. 
  47.  
  48. 2. Open the “PPC CodeGen” panel of the preferences dialog. Check the “Use Profiler” checkbox.
  49.  
  50. 3. Rebuild the library.
  51.  
  52.  
  53.  
  54. Automatic Modification of ODF Libraries
  55.  
  56. ODF includes an AppleScript that automatically enables profiling of all static ODF libraries and, optionally, the ODF shared library. If you want to automatically enable or disable profiling of the ODF libraries, execute the script at “ODFDev:ODF:Tools:Mac:Enable CWPPCProfiler”.  Usually, you will want to profile your part, not the ODF libraries, so this script may not apply.
  57.  
  58.  
  59.  
  60. Modifying Your Part
  61.  
  62. To enable profiling of your part, do the following:
  63.  
  64. 1. Open your part’s  project in CodeWarrior. 
  65.  
  66. 2. Open the “PPC CodeGen” panel of the preferences dialog. Check the “Use Profiler” checkbox.
  67.  
  68. 3. Add the ODFCWProfilerLib.PPC library you built earlier to your project. 
  69.  
  70. 4. Rebuild and install your part.
  71.  
  72.  
  73.  
  74. Enabling Profiling
  75.  
  76. Once the appropriate projects and libraries have been configured to profile, you must explicitly enable profiling of the code you want to measure. The header file “FWProfiler.h” contains declarations and comments relevant to profiling (the Metrowerks profiler library should not be called directly). All methods are described below:
  77.  
  78. FW_ProfilerSetStatus: Pass this function a value of TRUE to turn profiling on and a value of FALSE to turn profiling off. 
  79.  
  80. FW_ProfilerGetStatus: Returns TRUE if profiling is on, FALSE if profiling is off.
  81.  
  82. FW_ProfilerSetDumpFile:  Optionally call this method and provide a path, as a length-prefixed pascal string, indicating where the profiling information should be dumped. If this method is not called, profiler data will be dumped into a file called “ODFProfiler Dump” at the root of the startup disk. If the dump file already exists when a dump occurs, the first unique number beginning at 1 will be added to the file name.
  83.  
  84. FW_ProfilerUseDefaultDumpFile: Calling this method resets the dump file location to its default of “ODFProfiler Dump” at the root of the boot volume.
  85.  
  86. FW_ProfilerDump: Dumps the profiler buffer into the current dump file. Calling this method does not clear the profiler buffer.
  87.  
  88. FW_ProfilerClear: Clears the profiler buffer. This method does not affect the on/off status of the profiler.
  89.  
  90. An example of how to use these methods follows:
  91.  
  92.      #ifndef FWPROFILER_H
  93.      #include "FWProfiler.h"  // add at beginning of source files that
  94.      #endif                   // call FW_Profiler methods
  95.  
  96.      void CMyPart::SomeMethod()
  97.      {
  98.         FW_ProfilerSetDumpFile("\pHD:MyPartDumpFile");
  99.         FW_ProfilerSetStatus(TRUE);
  100.              ... call subroutines ...
  101.         FW_ProfilerDump();
  102.         FW_ProfilerSetStatus(FALSE);
  103.      }
  104.  
  105. Consult the Metrowerks documention for information on how to view and interpret profiler dump files.         
  106.  
  107. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  108. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.